<?php

namespace Core;

/**
 * Description of Session
 *
 * @author Admin
 */
class Session
{
	
	protected $_name;
	
	public static function start()
	{
		session_start();
	}
	
	public static function destroy()
	{
		session_destroy();
	}
	
	public function __construct($name)
	{
		if(!isset($_SESSION['core']))
			$_SESSION['core'] = array();
		
		$this->_name = $name;
	}
	
	public function __set($key, $val)
	{
		$_SESSION['core'][$this->_name][$key] = $val;
	}
	
	public function __get($key)
	{
		if(isset($_SESSION['core'][$this->_name][$key]))
			return $_SESSION['core'][$this->_name][$key];
		
		return null;
	}
	
	public function destruct()
	{
		if(isset($_SESSION['core'][$this->_name]))
			unset($_SESSION['core'][$this->_name]);
	}
	
	
	
}
